CUBE CONNECT Edition Help

FAQ - Network

How do I re-compute link distances in Voyager?

Use the Network module and do distance computation in the linkmerge phase:

DISTANCE=SQRT((A.X-B.X)*(A.X-B.X)+(A.Y-B.Y)*(A.Y-B.Y))

How do I renumber nodes in a network?

This can be done in Network with the LOOKUP function (See General Syntax). The following example illustrates the process:

; create a lookup file for node renumbering
 ; new# old#
 copy file=renumber.txt
 101 1
 102 2
 103 3
 104 4
 105 5
 106 6
 107 7
 108 8
 109 9
 110 10
 endcopy

 run pgm = network
 neti = input.net
 neto=output.net

 ; specify a lookup function, return 0 if no exact match
 lookup name=renum, file=renumber.txt, interpolate=f,
 fail=0,0,0

 phase=input filei=ni.1
if (renum(n)<>0) n=renum(n)
endphase

phase=input filei=li.1
if (renum(a)<>0) a=renum(a)
if (renum(b)<>0) b=renum(b)
endphase

endrun

How are speed and capacity tables handled in CUBE Voyager?

The values in the speed and capacity table are stored in the Voyager network in a separate area of the file. Each individual link only has the speed class (SPDC) and capacity class (CAPC) codings. The actual speed and capacity values are looked up dynamically from the speed and capacity tables based on the speed class, capacity class and number of lanes for a particular link; they are not stored as attributes in the link data itself. The speed and capacity tables allow up to 99 classes. To verify the speed and capacity tables, add the following statement to your first Network step:

REPORT CAPACITY=T,SPEED=T

The REPORT statement will generate a report on the speed and capacity table. If you want to obtain the actual speed and capacity value for a link you can use the SPEEDFOR(lanes,spdclass) and CAPACITYFOR(lanes,capclass) functions in Network to obtain them.

How can I include coordinates in link records?

Node coordinates are not part of link records. However, Network allows one to reference the x and y coordinates for the a and b nodes by a.x, a.y, b.x and b.y in a LINKMERGE phase. To put them in a LINKO file, follow the below example to create new link attributes so you can use them in the LINKO:

run pgm=network
neti=...
linko=name, form=..., format=txt,
include=a,b,a_x,a_y,b_x,b_y, ...
a_x=a.x
a_y=a.y
b_x=b.x
b_y=b.y

In Network, the LINKMERGE phase loops through the link database, and only the attributes of the current link (in all LINKI’s) can be referenced. To access reverse link attributes, one can read in the same network twice and switch the a_node and b_node of NETI[2] so that the reverse link in NETI

[2] has the same a_node and b_node as the current link in NETI[1]. The following example illustrates how to access reverse link volume to compute the total link volume:

run pgm=network
neti=input.net, input.net
neto=output.net
merge record=f
phase=input, filei=li.2
_temp=a
a=b
b=_temp
endphase
phase=linkmerge
totv=li.1.v_1+li.2.v_1
endphase
endrun

How can I compute a new node attribute using coordinates?

To do node attribute processing in Network, place the statements in the NODEMERGE phase; otherwise, all statements default to the LINKMERGE phase. The following example computes two new node attributes, XH and YH, equal to a hundred times of the X and Y coordinates, respectively.

PHASE=NODEMERGE
XH=100*X
YH=100*Y
ENDPHASE
PHASE=LINKMERGE
; link processing statements
ENDPHASE

Links are invisible when the coordinates of the a_node and/or b_node are zero. In those cases, CUBE cannot display the links. The follow sample code shows how to remove invisible links from a network:

RUN PGM=NETWORK
NETI=BASE.NET
NETO=NEW.NET
if ((a.x=0 && a.y=0) || (b.x=0 && b.y=0)) DELETE
ENDRUN

How do I get congested speed as an attribute?

You can compute the congested speed in Network after your assignment (or in CUBE). Use the equation:

CSPEED = DISTANCE / TIME_1 * 60

This assumes TIME_1 is the congested time. If you do an assignment using a loaded network as input, the new volume, time etc. will be sub-fixed with 2 and 3 etc. (such as TIME_2, V_2). Also, please pay attention to the units of the variables involved. The above equation assumes DISTANCE and TIME_1 are in miles and minutes, and the resulting SPEED is in mph.

Is there a way to output two-way link records from a network to text or DBF file?

Use the following script to write a network out in a two-way link format. If the attributes of a link and its reverse link are the same, only one record will be written out with a directional flag set to 2. Otherwise the link will be written out as one-way link with the directional flag set to 1. It reads the same network file as two separate NETI’s and reverses the A and B for the second NETI such that in the LinkMerge phase, data attributes for both directions are available at the same time. The example then uses the COMPARE command to determine if the links are the same in opposite directions.

RUN PGM=NETWORK
NETI=TEST.NET,TEST.NET ; same network as 2 NETI files
LINKO=TESTLINK.DBF ; output as link records in DBF format
NODEO=TESTXY.DBF
MERGE RECORD=F

PHASE=INPUT, FILEI=LI.2 ; reverse the A and B in file 2
_TEMP=A
A=B
B=_TEMP
ENDPHASE

PHASE=LINKMERGE
COMPARE RECORD=1-2 ; compare link record 1 with 2
IF (_COMPARE = 0) ; if same
IF (A < B) ; if low to high, write out 2-way link
REVERSE=2
ELSE
DELETE ; delete high to low side of 2-way link
ENDIF
ELSE
REVERSE = 1 ; if not same write as 1 way
ENDIF
ENDRUN

; This step will build the network back from the DBF files
RUN PGM=HWYNET

LINKI=TESTLINK.DBF, RENAME=REVERSE-REV ; set the REV attributes
NODEI=TESTXY.DBF
NETO=TEST2.NET
ENDRUN

Why is the footer plotted different from my specification?

The following FOOTER line will cause a problem because Network treats each space, “-” and “,” as field separators.

FOOTER=BASE YEAR 1997 NETWORK
TREASURE VALLEYI-84 CORRIDOR STUDY

Network will treat BASE as one field, YEAR as another field etc. It also sees the “-” in I-84 and assumes that it is a range but it doesn’t know what “I” is. Anytime you want to specify a string of characters with imbedded spaces or other special characters, you will need to enclose them within ” “. So changing the statement to:

FOOTER="BASE YEAR 1997 NETWORK",
" TREASURE VALLEY I-84 CORRIDOR STUDY"

should work in specifying FOOTER[1] and FOOTER[2].

How do I make global changes in a network?

In terms of making global changes in a network, you may want to look at the global calculation capabilities in CUBE Network Window. It allows you to make changes to the network globally or inside/outside/crossing a user-defined polygon area. You can also make changes based on some condition in the data record. See the Network Window chapter in the CUBE Base Reference Guide.

You can also perform calculations in the NODEMERGE and the LINKMERGE phases in the Network module of CUBE Voyager.

How do I build and un-build networks from/to ASCII files?

You can build and un-build networks from/to ASCII file using Voyager’s Network module. To build a network, use the LINKI and NODEI keywords in the FILEI statement to specify the filenames along with the VAR keyword to specify the variables and their locations. To output the network in ASCII, use the LINKO and NODEO keywords in the FILEO statement. You can also use the PRINT statement to write ASCII records to a file in whatever formats you wish.

Can Network read TRANPLAN networks in binary (UNIX) and ASCII formats?

Voyager can read a UNIX format TRANPLAN binary network file directly. You can also read the ASCII file just like any other link data file; you will need to define the fields for Voyager’s Network module to build a new network from ASCII records. The following is a sample on how to build a network from TRNAPLAN ASCII file (use the same file for LINKI and NODEI). This same code is available as a module template in CUBE in the Text Editor window under the Insert dropdown:

RUN PGM=NETWORK

FILEI LINKI={filename},VAR=A,1-5,B,6-10,ASGNGRP,11-11,DISTANCE,12-15,
SPEED1,17-20,SPEED2,21-24,DIRCODE,25-26,LINKGRP1,27-28,
LINKGRP2,29-30,LINKGRP3,31-32,CAPACITY,33-38,VOLUME,39-44,REV,45-45,
SELECT=(SUBSTR(RECORD,1,1)!='N'),
NODEI={filename},VAR=N,2-6,X,9-17,Y,20-28,
SELECT=(SUBSTR(RECORD,1,1)=='N')
FILEO NETO={filename}

ZONES={max zones}
IF (SPEED1 > 0) TIME1=DISTANCE/SPEED1*60
IF (SPEED2 > 0) TIME2=DISTANCE/SPEED2*60

ENDRUN

Is there a sample setup for calculating two-way volume?

The Highway module has an option to output the two-way volumes in the output network. If you want to add the two-way volume information to the network after the assignment is done, you can use the following script to set a 1-way/2-way flag in the link as well as combine the 1-way volumes into a 2-way volume. It reads the same network file as two separate NETI inputs, and reverses the A and B for the second NETI. Thus in the NETMERGE phase, the data attributes for both directions are available at the same time.

RUN PGM=NETWORK

NETI=LOAD.NET, LOAD.NET
NETO=LOD1.NET
MERGE RECORD=F ; DO NOT MERGE RECORDS

; Reverse end nodes of each link in NETI[2]
PHASE=INPUT, FILEI=LI.2
_TEMP=A
A=B
B=_TEMP
ENDPHASE
PHASE=LINKMERGE

; Index # of ways
IF (LI.2.A=0)
NUMWAYS=1 ; Oneway
ELSE
NUMWAYS=3 ; Twoway
ENDIF

; Calculate total volume on both direction
TOTV=LI.1.V_1+LI.2.V_1
ENDPHASE

ENDRUN

You can also use CUBE to compute the 2-way volume by adding a new link attribute (e.g. TOTV) and compute with the following equation for all links. See the Network Window chapter in the CUBE Base Reference Guide.

TOTV=V_1+V_1.R

The following example illustrates how to compute a new attribute (ONEWAY) indicating one-way links. The idea is to have the information on both directions available for the current link. So we read in the input network twice and reverse A and B nodes of NETI[2] in the NODEMERGE phase. Now the link attributes of both directions are available to the current link. When a link is not on a network, its A and B nodes are both zero. Therefore, by checking the A node value of the reverse links we can flag all one-way links.

run pgm=network
neti=input.net, input.net
neto=output.net
merge record=f

phase=input, filei=li.2
_temp=a
a=b
b=_temp
endphase

phase=linkmerge
if (li.2.a == 0) ONEWAY=1
endphase

endrun

How do I use Network to compare Volumes and VMT’s on two networks and report the frequency of percentage differences?

The following sample script illustrates how to compare Volumes and VMT’s on two networks and report the frequency of percentage differences.

The script compares link volumes and VMT’s on two network files. Frequency of percent difference in link volumes by volume group and that in VMT’s by speed class are reported.

; Volume on base (B) network -- L1.V_1
; Volume on subject (S) network -- L2.V_1
; Volume differences (S-B) -- VOL_DIFF
; VMT differences (S-B) -- VMT_DIFF
; Volume diff percentage (S-B)*100/B -- VOL_PCTDIFF
; VMT diff percentage (S-B)*100/B -- VMT_PCTDIFF
;
RUN PGM=NETWORK
NETI[1]=BASE.NET
NETI[2]=SUBJECT.NET
NETO=DIFF.NET
MERGE RECORD=F
; create a temporary variable '_COUNT' to accumulate link : counts
_COUNT=1
VOL_DIFF=L2.V_1-L1.V_1

; calculate percent differences of link volumes
; min out at -1000% and max out at 1000%
VOL_PCTDIFF=MAX(MIN((VOL_DIFF*100)/MAX(L1.V_1,0.001),100
0),-1000)
CROSSTAB VAR=_COUNT, ROW=L1.V_1, RANGE=0-100.0,100.1-
500.0,500.1-1000.0,
1000.1-5000.0,5000.1-10000.0,
10000.1-100000,0.0-100000.0,
COL=VOL_PCTDIFF, RANGE=-1000--100.1, -100--50.1,
-50--20.1, -20--10.1, -10--0.1, 0.0, 0.1-10, 10.1-20,
20.1-50, 50.1-100, 100.1-1000,
-10-10.0,-20.0-20,-50.0-50,-100.0-100,
-1000.0-1000

; Comparison of VMT
BASE_VMT=L1.V_1*L1.DISTANCE
SUBJ_VMT=L2.V_1*L2.DISTANCE
VMT_DIFF=SUBJ_VMT-BASE_VMT

; calculate percent differences of VMT
; min out at -1000% and max out at 1000% VMT_PCTDIFF=MAX(MIN((VMT_DIFF*100)/MAX(BASE_VMT,0.001),1 000),-1000)
CROSSTAB, VAR=_COUNT, ROW=L1.SPDCLASS, RANGE=1-10-1,1-10,
COL=VMT_PCTDIFF, RANGE=-100--50.1, -50--20.1, -20--10.1,
-10--0.1, 0.0, 0.1-10, 10.1-20,
20.1-50, 50.1-100, 100.1-1000,
-10-10.0,-20.0-20,-50.0-50,-100.0-100,
-1000.0-1000

ENDRUN

Is there a function in Voyager to merge networks based on a condition?

This can be done using Network. In this example, input network #1 has a condition field (link_attribute) indicating whether data will be merged from that network, or from network #2. The example assumes that the links in net2.net are a subset of the links in net1.net.

run pgm=network
neti=net1.net, net2.net
neto=net3.net
merge record=f

phase=linkmerge

if (li.1.link_attribute=0)
; link_attribute=li.1.link_attribute
linkclass=li.1.linkclass
capacity=li.1.capacity ; should list all link attributes
:
:
else
linkclass=li.2.linkclass
capacity=li.2.capacity
:
:
endif

endphase

endrun

How do I merge a zonal data file into the node portion of a Voyager network?

Open the zonal data file as an input node file. Since all input node files to Network must have a ‘N’ field, we must rename the zone field to ‘N’. If it is an ASCII file, just name the zone field ‘N’ in field definition.

; For ASCII zonal files
run pgm=network
neti=dtown.net
nodei[2]=zonedata.txt,
var=n, beg=1, len=5, ; name the zone field 'N'
var=sfdu, beg=6, len=12,
var=mfdu, beg=13, len=21
neto=dtown_zdat.net

endrun

If the file is a DBF, then rename ZONE to N using the RENAME sub- keyword. For example: ::

; For DBF zonal files
run pgm=network

neti=dtown.net
nodei[2]=zonedata.dbf, rename=zone-n ; rename the zone
                                     ; field to 'N'
neto=dtown_zdat.net

endrun

How do I flag or delete unconnected nodes globally?

The following script can optionally flag all unconnected nodes with a new node field (UNUSED=1) or delete them.

run pgm=network
neti=simple.net
list=a(6), file=used_n.dat
list=b(6), file=used_n.dat
endrun
run pgm=network
neti=simple.net
nodei[2]=used_n.dat, var=n
neto=new.net
merge record=f
phase=nodemerge
; if (n2.n==0) UNUSED=1 ; to flag unused nodes only
if (n2.n==0) delete ; delete unused nodes
endrun